module.exports = function ($scope, $resource, $modalInstance, bean, toaster) {
  $scope.bean;
  $scope.url = '/api/ac/mc/merchantNameCardServiceImpl/createNameCard'
  if (bean) {
      $scope.bean = bean;
      $scope.url = '/api/ac/mc/merchantNameCardServiceImpl/updateNameCard'
  } else {
      $scope.bean = {
          mer_name:'',
          mer_address:'',
          mer_tel:'',
          mer_time:''
      };
  }

  //添加
  $scope.ok = function () {
      $resource($scope.url, {}, {}).save($scope.bean, function (res) {
          if (res.errcode === 0) {
              toaster.success({ title: '', body: '操作成功' });
              $modalInstance.close();
          } else {
              toaster.error({ title: '', body: res.errmsg });
          }
      });
  }

  //取消
  $scope.close = function () {
      $modalInstance.dismiss('cancel');
  }

};